import { http } from '@/utils/request'
import type {
  RepairCategory,
  RepairCategoryAddRequest,
  RepairCategoryUpdateRequest,
  RepairCategoryQueryRequest,
  UpdateRequest,
  BaseResponse,
  PageResponse
} from '@/types'

// 创建维修类别
export const createCategory = (data: RepairCategoryAddRequest): Promise<BaseResponse<number>> => {
  return http.post('/category/add', data)
}

// 更新维修类别
export const updateCategory = (data: RepairCategoryUpdateRequest): Promise<BaseResponse<boolean>> => {
  return http.post('/category/update', data)
}

// 分页获取维修类别列表
export const getCategoryList = (data: RepairCategoryQueryRequest): Promise<BaseResponse<PageResponse<RepairCategory>>> => {
  return http.post('/category/list/page', data)
}

// 获取所有启用的维修类别
export const getActiveCategories = (): Promise<BaseResponse<RepairCategory[]>> => {
  return http.post('/category/list/active')
}

// 根据ID获取维修类别
export const getCategory = (data: UpdateRequest): Promise<BaseResponse<RepairCategory>> => {
  return http.post('/category/get', data)
}

// 删除维修类别
export const deleteCategory = (data: UpdateRequest): Promise<BaseResponse<boolean>> => {
  return http.post('/category/delete', data)
}
